<?php
namespace Components\Account\User;

class Adapter {
	static private $instance = [];

	public function __construct($config = []) {
		
	}

	static private function newClassName($key, $class_name, $parameter) {
		if(isset(self::$instance[$key]) && !empty(self::$instance[$key])) { return self::$instance[$key]; }

		$className = __NAMESPACE__ . '\\' . $class_name;
		if(!class_exists($className)) { throw new \Exception($className . ' is non-existent.'); }

		return self::$instance[$key] = new $className($parameter);
	}

	static public function getLogicInstance($parameter = []) {
		return self::newClassName('logic', 'Logic', $parameter);
	}

	static public function getValidationInstance($parameter = []) {
		return self::newClassName('validation', 'Validation', $parameter);
	}

	static public function getFilterInstance($parameter = []) {
		return self::newClassName('filter', 'Filter', $parameter);
	}

	static public function getModelInstance() {
		return self::$instance['model'] = new Model();
	}

	static public function getServiceInstance($parameter = []) {
		return self::newClassName('service', 'Service', $parameter);
	}

	static public function getAddressServiceInstance($parameter = []) {
		return self::newClassName('bank_info_service', 'Address\\Service', $parameter);
	}

	static public function getBankInfoServiceInstance($parameter = []) {
		return self::newClassName('bank_info_service', 'BankInfo\\Service', $parameter);
	}

	static public function getInfoServiceInstance($parameter = []) {
		return self::newClassName('info_service', 'Info\\Service', $parameter);
	}

	static public function getMessageServiceInstance($parameter = []) {
		return self::newClassName('message_service', 'Message\\Service', $parameter);
	}

	static public function getOrderServiceInstance($parameter = []) {
		return self::newClassName('order_service', 'Order\\Service', $parameter);
	}

	static public function getOrderLogicInstance($parameter = []) {
		return self::newClassName('order_logic', 'Order\\Logic', $parameter);
	}

	static public function getOrderProductsServiceInstance($parameter = []) {
		return self::newClassName('order_products_service', 'Order\\Products\\Service', $parameter);
	}

	static public function getWalletServiceInstance($parameter = []) {
		return self::newClassName('wallet_service', 'Wallet\\Service', $parameter);
	}

	static public function getWalletLogServiceInstance($parameter = []) {
		return self::newClassName('wallet_service_log', 'Wallet\\Log\\Service', $parameter);
	}

	static public function getWalletValidationInstance($parameter = []) {
		return self::newClassName('wallet_validation', 'Wallet\\Validation', $parameter);
	}

	static public function getWalletFilterInstance($parameter = []) {
		return self::newClassName('wallet_filter', 'Wallet\\Filter', $parameter);
	}

	static public function getTeamServiceInstance($parameter = []) {
		return self::newClassName('team_service', 'TeamService', $parameter);
	}

	static public function getWalletTransferLogServiceInstance($parameter = []) {
		return self::newClassName('wallet_transfer_service_log', 'Wallet\\Transfer\\Service', $parameter);
	}
}
